package com.example.answer.androdi_db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * DBHelper�̳���SQLiteOpenHelper����Ϊά���͹������ݿ�Ļ���
 * DBManager�ǽ�����DBHelper֮�ϣ���װ�˳��õ�ҵ�񷽷���
 * Person�����ǵ�person���Ӧ��JavaBean��
 * MainActivity����������ʾ�Ľ��档
 * @author Administrator
 *
 */

public class DBHelper1 extends SQLiteOpenHelper {  
   
     private static final String DATABASE_NAME = "android.db";  
     private static final int DATABASE_VERSION = 1;  
       
     public DBHelper1(Context context) {  
         //CursorFactory����Ϊnull,ʹ��Ĭ��ֵ  
         super(context, DATABASE_NAME, null, DATABASE_VERSION);  
     }  
   
     //���ݿ��һ�α�����ʱonCreate�ᱻ����  
     @Override  
     public void onCreate(SQLiteDatabase db) {  
         db.execSQL("CREATE TABLE IF NOT EXISTS person" +  
                 "(id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR, age INTEGER, info TEXT)");  
     }  
   
     //���DATABASE_VERSIONֵ����Ϊ2,ϵͳ�����������ݿ�汾��ͬ,�������onUpgrade  
     @Override  
     public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {  
         db.execSQL("ALTER TABLE person ADD COLUMN other STRING");  
     }  
 }  

